package algorithms.que12;

import edu.princeton.cs.algs4.Counter;

/**
 * @功能
 * @创建时间 2020/6/21
 */
public class BinarySearch9 {
    public static void main(String[] args) {

    }
    public static Counter rank(int[] arr, int x, Counter counter){
        int min=0;
        int max=arr.length-1;
        while (max>min){
            counter.increment();
            int middle=min+(max-min)/2;
            if(arr[middle]>x)
                max=middle-1;
            if(arr[middle]<x)
                min=middle+1;
           if(arr[middle]==x)
               return counter;
        }
        return counter;
    }
}
